﻿using System;
using System.Collections.Generic;
using GeoAPI.Geometries;

namespace NetTopologySuite.Geometries.Utilities
{
	public class ComponentCoordinateExtracter : IGeometryComponentFilter
	{
		public static List<Coordinate> GetCoordinates(IGeometry geom)
		{
			List<Coordinate> list = new List<Coordinate>();
			geom.Apply(new ComponentCoordinateExtracter(list));
			return list;
		}

		public ComponentCoordinateExtracter(List<Coordinate> coords)
		{
			this._coords = coords;
		}

		public void Filter(IGeometry geom)
		{
			if (geom is ILineString || geom is IPoint)
			{
				this._coords.Add(geom.Coordinate);
			}
		}

		private readonly List<Coordinate> _coords;
	}
}
